<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<cw:base />
	</head>
	<body>
	<ul>
		<li>
			<b>表格加载验证允许加载表格数据后立即对数据进行有效性检查，标记处无效的数据。</b>
		</li>
		<li>
			<b>表格构件提供对其视图view绑定cellvalidate事件，事件的处理函数function(gv, p, c, rowIndex, i, ds)返回值是true或false，表示该单元格数据是否有效。</b>
		</li>
	</ul>
	<br/>
	<br/>
	<ul>
		<li>
			对年龄小于18岁的人员，标记其年龄单元格无效
				<cw:grid id="grid1" title="表格加载验证"
					url="../../../../sample/grid/grid.query.action"
					enablePage="false" exportable="false" selectMode="checkbox"
					urlParams="{id:0}"
					stripeRows="true" stripleColor="#c0c" autoLoad="true">
					<cw:indexColumn />
					<cw:gridColumn property="id" width="60" title="编号" summaryType="count" />
					<cw:gridColumn property="name" width="120" title="姓名" />
					<cw:gridColumn property="email" width="30%" />
					<cw:gridColumn property="age" width="80" title="年龄" summaryType="average" summaryDecimalPrecision="0" />
					<cw:gridColumn property="birthday" width="120" dataType="date" format="Y-m-d" />
					<cw:gridColumn property="sex" width="80" rendererData="[[1,'男'],[2,'女']]" />
					<cw:gridColumn property="created" width="120" title="创建时间" dataType="date" format="Y-m-d" />
				</cw:grid>
				<br />
		</li>
	</ul>
		<script>
			cf_r(function(){
				var grid = Ext.getCmp('grid1');
				var view = grid.getView();
				//表格数据加载时验证
				view.on('cellvalidate', function(gv, p, c, rowIndex, i, ds){
					if (p.value==null || p.value=='')
						return false;
					if (p.id==5 && parseInt(p.value)<18)
						return false;
				});
			});
		</script>
	</body>
	<cw:theme></cw:theme>
</html>